<?php


namespace App\Component;


use Hyperf\Redis\Redis;

class RedisUidBandServer implements UidBandServerInterface
{

    private Redis $redis;
    private string $hashName;


    public function __construct($redis, string $hashName)
    {
        $this->redis = $redis;
        $this->hashName = $hashName;
    }

    public function get($key)
    {
        return $this->redis->hGet($this->hashName, (string)$key);
    }

    public function set($key, $value)
    {
        return $this->redis->hSet($this->hashName, (string)$key, $value);
    }

    public function del($key)
    {
        return $this->redis->hDel($this->hashName, (string)$key);
    }

    public function exist($key)
    {
        return $this->redis->hExists($this->hashName, (string)$key);
    }

    public function clear()
    {
        return $this->redis->del($this->hashName);
    }
}